home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Python 1.4 / Python 1.4 source / Mac / Modules / res / resscan.py < prev    next >
Encoding:
Python Source  |  1996-04-15  |  1.8 KB  |  71 lines  |  [TEXT/Pyth]

  1. # Scan Resources.h header file, generate resgen.py and Resources.py files.
  2. # Then run ressupport to generate Resmodule.c.
  3. # (Should learn how to tell the compiler to compile it as well.)
  4.  
  5. import sys
  6. import os
  7. import string
  8. import regex
  9. import regsub
  10. import MacOS
  11. import addpack
  12. addpack.addpack(':Tools:bgen:bgen')
  13. from bgenlocations import TOOLBOXDIR
  14.  
  15. from scantools import Scanner
  16.  
  17. def main():
  18.     input = "Resources.h"
  19.     output = "resgen.py"
  20.     defsoutput = TOOLBOXDIR + "Resources.py"
  21.     scanner = ResourcesScanner(input, output, defsoutput)
  22.     scanner.scan()
  23.     scanner.close()
  24.     print "=== Done scanning and generating, now doing 'import ressupport' ==="
  25.     import ressupport
  26.     print "=== Done 'import ressupport'.  It's up to you to compile Resmodule.c ==="
  27.  
  28. class ResourcesScanner(Scanner):
  29.  
  30.     def destination(self, type, name, arglist):
  31.         classname = "ResFunction"
  32.         listname = "functions"
  33.         if arglist:
  34.             t, n, m = arglist[0]
  35.             if t == "Handle" and m == "InMode":
  36.                 classname = "ResMethod"
  37.                 listname = "resmethods"
  38.         return classname, listname
  39.  
  40.     def makeblacklistnames(self):
  41.         return [
  42.             "ReadPartialResource",
  43.             "WritePartialResource",
  44.             "TempInsertROMMap",
  45. ##            "RmveResource",        # RemoveResource
  46. ##            "SizeResource",        # GetResourceSizeOnDisk
  47. ##            "MaxSizeRsrc",        # GetMaxResourceSize
  48.             ]
  49.  
  50.     def makerepairinstructions(self):
  51.         return [
  52.             ([("Str255", "*", "InMode")],
  53.              [("*", "*", "OutMode")]),
  54.             
  55.             ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
  56.              [("InBuffer", "*", "*")]),
  57.             
  58.             ([("void", "*", "OutMode"), ("long", "*", "InMode")],
  59.              [("InOutBuffer", "*", "*")]),
  60.             
  61.             ([("void", "*", "OutMode"), ("long", "*", "InMode"),
  62.                                         ("long", "*", "OutMode")],
  63.              [("OutBuffer", "*", "InOutMode")]),
  64.              
  65.             ([("SInt8", "*", "*")],
  66.              [("SignedByte", "*", "*")])
  67.             ]
  68.  
  69. if __name__ == "__main__":
  70.     main()
  71.